package com.bootcamp.javase.polymorph.test_interface;

/**
 * @program: PolyMorphCode
 * @description:
 * @author: Keyu Li
 * @create: 2021-09-02 21:37
 **/

public class TestInterface {
    public static void main(String[] args) {
        Person pt = new Teacher("da wang", "male", 55);
        Person ps = new Student("xiao wang", "male", 22);
        Teacher tt=  new Teacher("da li", "female",66);
        Student ss = new Student("xiao li", "female", 18);

        pt.eat();
        pt.sleep();
        ((Teacher) pt).learnSkill();

        ps.eat();
        ps.sleep();
        ((Student) ps).learnSkill();

        tt.eat();
        tt.sleep();
        tt.learnSkill();

        ss.eat();
        ss.sleep();
        ss.learnSkill();
    }
}

abstract class Person{
    String name;
    String gender;
    int age;

    public Person(String name, String gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
    }

    abstract void eat();
    abstract void sleep();
}

class Teacher extends Person implements ExtraSkills{
    public Teacher(String name, String gender, int age) {
        super(name, gender, age);
    }

    void eat(){
        System.out.println("在教师餐厅吃！");
    }
    void sleep(){
        System.out.println("在教师公寓休息！");
    }

    @Override
    public void learnSkill() {
        System.out.println("学习强国！");
    }
}

class Student extends Person implements ExtraSkills{
    public Student(String name, String gender, int age) {
        super(name, gender, age);
    }

    void eat(){
        System.out.println("在学生餐厅吃！");
    }
    void sleep(){
        System.out.println("在学生宿舍休息！");
    }

    @Override
    public void learnSkill() {
        System.out.println("青年大学习！");
    }
}
